<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ include file="/common/taglibs.jsp" %>	
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- css js-->
	<script type="text/javascript">
     function doSearch() {
   		$('#dg').datagrid('options').pageNumber=1;//设置页码初始值为1
   	    $('#dg').datagrid({
   	        queryParams : $('#sform').serializeObject()
   	    });
	  }
     
   function editEnterprise(gid, wid, url) {
 		var row = $('#' + gid).datagrid('getSelected');
 		if (row != null) {
 			$('#' + wid).window('open');
 			$('#' + wid).window('refresh', url + '?id=' + row.qybh);
 		} else {
 			$.messager.alert('警告', '请选择要修改的记录！');
 		}
   }
     
   function deleteEnterprise(gid, url) {
 		var row = $('#' + gid).datagrid('getSelected');
 		if (row != null) {
 			$.messager.confirm('确认', "确认删除吗？", function(r) {
 				if (r) {
 					$.ajax({
 						type : 'post',
 						url : url,
 						data : {
 							'id' : row.qybh
 						},
 						dataType:'json',
 						success : function(data) {
 							if (data) {
 								if (data.ack_code == "SUCCESS") {
 									showMsg('提示', data.data);
 									if (gid && gid != '') {
 										$('#' + gid).datagrid({});
 									}
 								} else {
 									showMsg('提示', data.data);
 								}
 							} else {
 								showMsg('提示', '删除失败！');
 							}
 						}
 					})
 				}
 			})
 		} else {
 			$.messager.alert('警告', '请选择要删除的记录！');
 		}
 	}
   
   function batchDelEnterprise(gid, url) {
		var rows = $('#' + gid).datagrid('getSelections');
		var ids = "";
		for (var i = 0; i < rows.length; i++) {
			ids += rows[i].qybh + ","
		};
		ids = ids.substr(0, ids.length - 1);
		if (ids != '') {
			$.messager.confirm('确认', "确认删除吗？", function(r) {
				if (r) {
					$.ajax({
						type : 'post',
						url : url,
						data : {
							'ids' : ids
						},
						success : function(data) {
							if (data) {
 								if (data.ack_code == "SUCCESS") {
 									showMsg('提示', data.data);
 									if (gid && gid != '') {
 										$('#' + gid).datagrid({});
 									}
 								} else {
 									showMsg('提示', data.data);
 								}
 							} else {
 								showMsg('提示', '批量删除失败！');
 							}
						}
					})
				}
			})
		} else {
			$.messager.alert('警告', '请选择要删除的记录！');
		}
	}
	</script>
<title>街镇列表</title> 
</head>
<body style="margin:0;padding:0">
     <div id="cc" class="easyui-layout"  data-options="fit:true">
     <%--查询条件--%>
	<div id="tb" style="padding: 10px;">
        <form id="sform" method="post">
            <input name="wfds" id="wfds" class="easyui-searchbox" data-options="prompt:'请输入单位名称，企业代码...',searcher:doSearch" style="width:33%">
            <a href="javascript:void(0);" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="showWin('win','${ctx}/Enterprise/showModify');">新增</a>
            <a href="javascript:void(0);" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="editEnterprise('dg','win','${ctx}/Enterprise/showModify');">修改</a>
            <a href="javascript:void(0);" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="deleteEnterprise('dg','${ctx}/Enterprise/delete')">删除</a>
            <a href="javascript:void(0);" class="easyui-linkbutton" iconCls="icon-bdel" plain="true" onclick="batchDelEnterprise('dg','${ctx}/Enterprise/batchDel')">批量删除</a>
        </form>
	 	<div id="win" class="easyui-window" title="企业信息管理"
	        data-options="iconCls:'${icon}',collapsible:false,minimizable:false,maximizable:false,closed:true"
	        style="width: 660px; height: 430px; background-color: white;"></div>
    </div>
	 <%--查询条件--%>
	<%--查询结果列表--%>
		<table class="easyui-datagrid" id="dg" style="width: 100%; height: 100%; padding: 0px;"
	        data-options="
	                border:false,
	                rownumbers:true,
	                singleSelect:false,
	                autoRowHeight:false, 
	                pagination:true,
	                toolbar:'#tb',
	                url:'${ctx}/Enterprise/search',
	                pageSize:20">
			<thead>
				<tr>
					<th data-options="field:'ck',checkbox:true"></th>
					<th field="qybh" hidden=true>qybh</th>
					<th field="dwdm" width="10%" align="center">企业代码</th>
					<th field="dwmc" width="10%" align="center">单位名称</th>
					<th field="gsdjh" width="10%" align="center">工商登记号</th>
					<th field="dwlx" width="10%" align="center">单位类型</th>
					<th field="dwdz" width="10%" align="center">单位地址</th>
					<th field="hy" width="10%" align="center">所属行业</th>
					<th field="gm" width="10%" align="center">企业规模</th>
					<th field="clrq" width="10%" align="center">成立日期</th>
					<th field="zczb" width="10%" align="center">注册资本</th>
				</tr>
			</thead>
		</table>
     	<%--查询结果列表完--%>   
    </div>
</body>
</html>
